﻿/// <reference path='../typings/angularjs/angular.d.ts'/>
/// <reference path='../typings/angularjs/angular-resource.d.ts'/>
/// <reference path='../typings/angularjs/angular-route.d.ts'/>

angular.module('Sustainalytics.Common', []);

var appRoot = angular

    .module('main',
    [
    //// Angular modules 
        'ngResource',       // $resource for REST queries
    //'ngAnimate',        // animations
        'ngRoute',      // routing
        'angularFileUpload',
        'ui.date',
        'ui.bootstrap',
        'textAngular',
        'ngTagsInput', // ngTagsInput directive - https://github.com/mbenford/ngTagsInput
        'Sustainalytics.Pager',
        'Sustainalytics.News',
        'Sustainalytics.Events',
        'Sustainalytics.Common', 
        'Sustainalytics.Insights',
        'Sustainalytics.Tools',
        'Sustainalytics.Accounts',
        'Sustainalytics.Universes',
        'Sustainalytics.ProductInvolvement',
        'Sustainalytics.EsgRatings',
        Sustainalytics.GovernanceReports.governanceReportsModuleName,
        Sustainalytics.Claims.claimsModuleName,
        Sustainalytics.Authentication.authenticationModuleName,
        Sustainalytics.Routing.routingModuleName, 
        'Sustainalytics.LRTM', 
        'Sustainalytics.LRTMTest',
        'Sustainalytics.SearchBox',
        'Sustainalytics.Company',
        'Sustainalytics.CompanySearch'
    ])

    .directive('hideLogin', function ($document) {
        return {
            restrict: 'A',
            link: function (scope, elem, attr, ctrl) {
                elem.bind('click', function (e) {
                    e.stopPropagation();
                });
                $document.bind('click', function () {
                    scope.$apply(attr.hideLogin);
                })
            }
        }
    })

    .service("sharedProperties", function () {
        var objectValue = {
            data: null
        }

        return {
            setObject: function (value) {
                objectValue = value;
            },
            getObject: function () {
                return objectValue;
            }
        };
    });
